package com.xcc.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Description: DirectRabbitConfig
 * @Author xiechuang
 * @Date 2022/12/1
 */
@Configuration
public class DirectRabbitConfig {

    /**
     * 队列
     *
     * @return
     */
    @Bean
    public Queue directQueue() {
        return new Queue("directQueue", true);
    }

    /**
     * 交换机
     *
     * @return
     */
    @Bean
    DirectExchange directExchange() {
        return new DirectExchange("directExchange", true, false);
    }

    /**
     * 绑定
     *
     * @return
     */
    @Bean
    Binding directBinding() {
        return BindingBuilder.bind(directQueue()).to(directExchange()).with("directBinding");
    }

    @Bean
    DirectExchange lonelyDirectExchange() {
        return new DirectExchange("lonelyDirectExchange");
    }

}
